﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebInterface;

namespace WebAppHappyNewYear.Controllers
{
    public class MyController : Controller
    {
        private readonly ITransitService _transitService;
        private readonly IScopedService _scopedService;
        private readonly ISingleService _singleService;

        public MyController(ITransitService transitService, IScopedService scopedService,ISingleService singleService)
        {
            _transitService = transitService;
            _scopedService = scopedService;
            _singleService = singleService;
        }
        public IActionResult Index()
        {
            _singleService.CreateInstance();
            _singleService.Start();
            Console.WriteLine(_singleService.ReturnCurrentMessage());
            return View();
        }


        public async Task<IActionResult> SelfDoSomething()
        {
            base.ViewData["single"] = await _singleService.SelfDoSomething($"Set Single Time: {DateTime.Now.ToString("yy-MM-dd HH:mm:ss fff")}");
            return View();
        }

        public async Task<IActionResult> OtherServiceDoSomething()
        {
            base.ViewData["single"] = await _singleService.OtherServiceDoSomething();
            return View();
        }


        public IActionResult TransitScopeDo()
        {
            base.ViewData["transit"] =  _transitService.GetParameter();
            base.ViewData["scope"] = _scopedService.GetParameter();
            return View();
        }
    }
}